package com.sali.biz;

import com.sali.service.ITestService;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @description: 方法注入实现方式 2
 * @author: sali
 * @date: 2024/8/26 下午1:54.
 * @version: 1.0
 */
@Component
public class BizStrategy02 {

    List<ITestService> serviceList = new ArrayList<>();

    BizStrategy02(List<ITestService> abstractServiceList) {
        serviceList.addAll(abstractServiceList);
        serviceList.stream().sorted(Comparator.comparingInt(ITestService::getSort));
    }


    public void workService() {
        for (ITestService myService : serviceList) {
            myService.doLogic();
        }
    }

}
